#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 110;
int a[N][N];
int f[N][N];
int r, c;
int ret = 1;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
int dfs(int i, int j)
{
    if (f[i][j])
    {
        return f[i][j];
    }
    int len = 1;
    for (int k = 0; k < 4; k++)
    {
        int x = dx[k] + i;
        int y = dy[k] + j;
        if (a[x][y] >= a[i][j] || x<1 || x>r || y<1 || y>c)
        {
            continue;
        }
        len = max(dfs(x, y) + 1, len);
    }
    return f[i][j] = len;
}
int main()
{
    cin >> r >> c;
    for (int i = 1; i <= r; i++)
    {
        for (int j = 1; j <= c; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= r; i++)
    {
        for (int j = 1; j <= c; j++)
        {
            ret = max(ret, dfs(i, j));
        }
    }
    cout << ret;
    return 0;
}